package com.hadoop.temperature;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class Group extends WritableComparator {

	public Group() {
		super(KeyPair.class, true);
	}

	// reduce的二次排序阶段，根据year进行分组
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		KeyPair k1 = (KeyPair) a;
		KeyPair k2 = (KeyPair) b;

		// Integer.compare默认是升序
		return Integer.compare(k1.getYear(), k2.getYear());
	}
}
